package com.hdax.ssm.service.impl;

import com.hdax.ssm.dao.RolePermissionDao;
import com.hdax.ssm.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RolePermissionServiceImpl implements RolePermissionService {
    @Autowired
    private RolePermissionDao rolePermissionDao;
    @Override
    public List<Long> getRolePermissionByRoleId(long roleId) {
        return rolePermissionDao.getRolePermissionByRoleId(roleId);
    }

    @Override
    public int delAllByRoleId(long roleId) {
        return rolePermissionDao.delAllByRoleId(roleId);
    }

    @Override
    public int addPermissionByRoleId(long roleId, String ids) {
        String[] idsStr = ids.split("-");
        for (String s :idsStr) {
            rolePermissionDao.addPermissionByRoleId(roleId,s);
        }
        return 0;
    }
}
